﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Loyalty.Core.Entities
{
    public class ProfileGrade
    {
        public virtual int Id { get; set; }

        public virtual Grade Grade { get; set; }

        public virtual int? LinkGradeId { get; set; }

        public virtual UniversityCourse UniversityCourse { get; set; }

        public virtual int? LinkUniversityCourseId { get; set; }

        public virtual Profile Profile { get; set; }

        public virtual int? LinkProfileId { get; set; }
        
        public virtual string UniversityTitle { get; set; }

        public virtual DateTime FromYear { get; set; }

        public virtual DateTime ToYear { get; set; }

        public virtual bool IsStuding { get; set; }

    }
}


namespace Loyalty.Core.Entities.Mapping
{
    public class ProfileGradeMap:EntityTypeConfiguration<ProfileGrade>
    {
        public ProfileGradeMap()
        {
            this.ToTable("ProfileGrade");
            this.HasKey(x => x.Id);

            this.Property(x => x.UniversityTitle).HasColumnName("UniversityTitle").HasMaxLength(200);
            this.Property(x => x.FromYear).HasColumnName("FromYear");
            this.Property(x => x.ToYear).HasColumnName("ToYear");
            this.Property(x => x.IsStuding).HasColumnName("IsStuding");

            this.HasOptional(x => x.Grade).WithMany(x => x.ProfileGrades).HasForeignKey(x => x.LinkGradeId);
            this.HasOptional(x => x.UniversityCourse).WithMany(x => x.ProfileGrades).HasForeignKey(x => x.LinkUniversityCourseId);
            this.HasOptional(x => x.Profile).WithMany(x => x.ProfileGrades).HasForeignKey(x => x.LinkProfileId);
        }
    }
}